<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("modelConfigPath", "stock");
%>
<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style type="text/css">
	.form-detailed .heading-btn.pull-right-important{float:right !important;}
	.table-responsive{margin: 0px 10px 0px 10px !important;}
	td input{margin-top:-1px;margin-bottom:-1px;height:23px; width:100%;border:none;color:red}
</style> 
<t:form id="form" modelAttribute=""  method="POST" action="/stock/inventory/saveInventoryShow" cssClass="form-horizontal">
	<input type="hidden" value='${inventory.inventoryId}' id="inventoryId" name="inventoryId"/> 
	<input type="hidden" value='' id="inventoryState" name="inventoryState"/>
	<input type="hidden" value="" id="endType" name="endType"/> 
	<input type="hidden" value="${inventory.inventoryType}" id="inventoryType" name="inventoryType"/>
	
	<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
		<div class="table-responsive">
			<div style="height:497px;overflow-y:auto; overflow-x:auto;" >
				<table class="table table-bordered text-left">
				   <tr>
				   	  <td >盘点单号</td>	 
				   	  <td >${inventory.inventoryNo}</td> 
				   	  <td >盘点日期</td>
				   	  <td ><fmt:formatDate value="${inventory.createDate}" type="date" dateStyle="default" pattern="yyyy-MM-dd HH:MM:SS"/></td>
				   	  <td >盘点人</td>	 
				   	  <td >${inventory.createUserName}</td> 
				   </tr>
				</table>
				<table class="cntable table table-bordered dataTable table-serveProject">
					<thead>
						<tr>
							<th>序号</th>
							<th>编号</th>
				            <th>名称</th>
				            <th>属性</th>
				            <th>账面库存</th>
				            <th>实盘库存</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="inventoryShow" items="${inventoryShows}"  varStatus="status">
							<c:set var="trShow"  value="0"/>
							<c:set value="" var="trColor" />
							<tr>
								<c:forEach var="inventoryCollocation" items="${inventoryShow.inventoryCollocations}">
									<input type="hidden" value='${outStockShow.cargoId}' id="cargoId" name="cargoId"/>
									<input type="hidden" value='${inventoryCollocation.collocationId}' id="collocationId" name="collocationId"/>
									<c:set var="trShow"  value="${trShow +1}"/>
									<c:if test="${trShow == 1}" >
										<td rowspan="${fn:length(inventoryShow.inventoryCollocations)}">${status.index+1}</td>
										<td rowspan="${fn:length(inventoryShow.inventoryCollocations)}">${inventoryShow.cargo.cargoNo}</td>
										<td rowspan="${fn:length(inventoryShow.inventoryCollocations)}">${inventoryShow.cargo.cargoName}</td>
										<td>${inventoryCollocation.collocation.propertyNameOne}/${inventoryCollocation.collocation.propertyNameTwo}</td>
										<td>${inventoryCollocation.bookNumCollocation}</td>
										<td><input style="ime-mode:disabled" onkeyup="return ValidateNumber(this,value)" name="actualNumCollocation" type="text" value="${inventoryCollocation.actualNumCollocation}"/></td>
									</c:if>
									<c:if test="${trShow > 1}" >
										<tr>
											<td>${inventoryCollocation.collocation.propertyNameOne}/${inventoryCollocation.collocation.propertyNameTwo}</td>
											<td>${inventoryCollocation.bookNumCollocation}</td>
											<td><input style="ime-mode:disabled" onkeyup="return ValidateNumber(this,value)" name="actualNumCollocation" type="text" value="${inventoryCollocation.actualNumCollocation}"/></td>
										</tr>
									</c:if>
								</c:forEach>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
				<t:button icon="icon-floppy-disk" onclick="submitForm()" laddaType="progress" data-endType="unAdjustment" data-inventoryState="1" cssClass="btn-info" csize="sm" >保存草稿</t:button>
				<t:button icon="icon-floppy-disk" onclick="submitForm()" laddaType="progress" data-endType="unAdjustment" data-inventoryState="2" cssClass="btn-info" csize="sm" >不调整，直接结束</t:button>
				<t:button icon="icon-floppy-disk" onclick="submitForm()" laddaType="progress" data-endType="adjustment" data-inventoryState="2" cssClass="btn-info" csize="sm" >调整库存并结束库存</t:button>
			</t:panelFoot>
		</div>
	</t:panel>
</t:form>
<script type="text/javascript">

function submitForm(lbtn){
	$("#endType").val(arguments[1].attr("data-endType"));
	$("#inventoryState").val(arguments[1].attr("data-inventoryState"));
	if($("[name='collocationId']").val()==null){
		$.showTips("请选择盘点货品数量！",1000,"warning");
		return;
	}
	$("input[name='actualNumCollocation']").each(function(){
	    var actualNumCollocation=parseFloat($(this).val());
	    if(isNaN(actualNumCollocation)){
	    	$(this).val(0.0);
	    }
	});

	if (!$("form:first").valid()){
		return;
	}
	lbtn.start();
	$("#form").submit();
}

//输入框数字输入限制
function ValidateNumber(e, pnumber){
	if (!/^\d+[.]?\d*$/.test(pnumber))
	{
	e.value = /^\d+[.]?\d*/.exec(e.value);
	}else{
		
 	}
	return false;
}	
</script>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>